#include <bits/stdc++.h>
// 2025/03/12
// tag: 
// Author: Forever
using namespace std;
#pragma GCC optimize(3)
using int64 = int64_t;
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--){
        string s;
        cin >> s;
        bool flag = false;
        for (int i = 0; i < s.size() - 1; i++)
            if (s[i] == s[i + 1])
                flag = true;
        if (flag)
            cout << 1 << endl;
        else
            cout << s.size() << endl;
    }
    return 0;
}